<!DOCTYPE html>
<html lang="en" class="no-js">
    {% include "ic/head.html" with context %}

<body>
    <svg class="hidden">
        <defs>
            <path id="tabshape" d="M80,60C34,53.5,64.417,0,0,0v60H80z"/>
        </defs>
    </svg>

<!--
<div class="hook" id="hook"></div>
-->
    <div id="wrapper">
        <nav class="navbar navbar-default navbar-fixed-top primo-menu" role="navigation">
             <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="/italiaCives"></a>

           </div>
<!--
               <ul  style="background:white" class="nav navbar-nav navbar-right denom">
-->
<!--
                <li>
-->
                    <p class="nav navbar-text navbar-right denom">{{pageData["ente_def"].denominazione}}</p>
<!--
                    </li>
-->
<!--
            </ul>
-->
            </div>
        </nav>
        <div class="navbar navbar-default navbar-fixed-top secondo-menu">
            <ul class="col-sm-12 col-lg-12">
               <li class="col-sm-10 col-lg-10 pull-left"><p class="pagg">ItaliaCives</p></li>
                <li style="align:right;" class="dropdown col-sm-2 col-lg-2 pull-right">
                    <a  class="dropdown-toggle"  data-toggle="dropdown" href="#">
                        <i style="color:white" class="fa fa-bars fa-lg"></i>
                    </a>
                    <ul class="nav dropdown-menu dropdown-user">
                        <li><a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a>
                        </li>
                        <li><a href="#myModal" role="button" data-toggle="modal"><i class="fa fa-refresh"></i>Cambia comune</a>
                        </li>
                        <li class="divider"></li>
                        <li><a href="/italiaCives/logout"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
                        </li>
                    </ul>
                    <!-- /.dropdown-user -->
                </li>
            </ul>
        </div>
        <!-- /. NAV TOP  -->
    {#% include "ic/sidebar-sx.html" with context %#}
        <div id="page-wrapper" >
            <div id="page-inner">
    {% block content %}
            <section>
                <div class="tabs tabs-style-underline" id="myTabs" >
                    <nav>
                        <ul >
                            <li class="active"><a data-toggle='tab' style="text-decoration:none;" href="#home" nome="ItaliaCives" data-url="/italiaCives/dashboard_stream" class="fa fa-home fa-2x">
                                </a></li>
                            <li><a data-toggle='tab' style="text-decoration:none;" href="#news" nome="Notizie" data-url="/italiaCives/news" class="fa fa-rss fa-2x">
                                </a></li>
                            <li><a data-toggle='tab' style="text-decoration:none;" href="#eventi" nome="Eventi" data-url="/italiaCives/news?tipo=eventi"  class="fa fa-bullhorn fa-2x" >
                                </a></li>
                            <li id="pippo2" ><a data-toggle='tab' style="text-decoration:none;" href="#segnalazioni" nome="Segnalazioni" data-url="/italiaCives/segnalazioni/" class="fa fa-edit fa-2x">
                                </a></li>
                            <li><a data-toggle='tab' style="text-decoration:none;"href="#comune" nome="Comune" data-url="/italiaCives/comune_servizi?show=embedded&tipo=comune" class="fa fa-bank fa-2x">
                                </a></li>
                            <li><a data-toggle='tab' style="text-decoration:none;" href="#servizi" nome="Commercio e Servizi" data-url="/italiaCives/comune_servizi?show=embedded&tipo=servizi" class="fa fa-thumb-tack fa-2x">
                                </a></li>
                        </ul>
                    </nav>
                    <div class="content-wrap">
                        <section id="home" class="tab-pane active" >
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                        <section id="news"  class="tab-pane">
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                        <section id="eventi" class="tab-pane" >
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                        <section id="segnalazioni"  class="tab-pane">
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                        <section id="comune" class="tab-pane">
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                        <section id="servizi" class="tab-pane">
                            <p style="text-align:center;">
                                <img src="/tpl/img/ajax-loader.gif">
                            </p>
                        </section>
                    </div><!-- /content -->
                </div><!-- /tabs -->
            </section>
    {% endblock %}

</div><!-- /page-inner -->
    <a href="#top" id="toTop"></a>
</div><!-- /page-wrapper -->
</div><!-- /wrapper -->
   <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <form class="omb_loginForm" action="/italiaCives/dashboard" autocomplete="off" method="POST">
                <input type="hidden" name="id_ente" id="id_ente" value=""/>
                <h3 class="help-block">Cerca un altro comune:</h3>
            </div>
            <div class="modal-body">
                 <div class="col-xs-12 col-sm-12 col-lg-12 input-group">
                    <input class="form-control" type="text" name="ente" id="ricerca_entry_articolo_modal" placeholder="Inserisci qui la tua ricerca" >
                    <a class="search_cmplx input-group-addon" id="ricerca_complessa_articolo" href="#">
                        <span class=" glyphicon glyphicon-search" data-toggle="modal" data-target="#myModal"></span>
                    </a>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn  btn-primary btn-block" type="submit">Cambia</button>
            </div>
            </form>
        </div>
    </div>
</div>
    {% include "ic/scripts.html" with context %}

{% block custom_js %}
<script type="text/javascript">
$(document).ready(function(){
    $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });

     //load first tab content
    $('#home').load($('.active a').attr("data-url"),function(result){
      //$('.active a').tab('show');
      var nome = $(this).attr("nome");
      $(".pagg").text(nome);

    });

    (function() {

        [].slice.call( document.querySelectorAll( '.tabs' ) ).forEach( function( el ) {
            new CBPFWTabs( el );
        });

    })();

    $('#myTabs a').click(function (e) {
        //e.preventDefault();

        var url = $(this).attr("data-url");
        //console.log(url);
        var href = this.hash;
        //console.log(href);
        var pane = $(this);
        //console.log(pane);
        var nome = $(this).attr("nome");
        //console.log(nome)
        // ajax load from data-url
        $(".pagg").text(nome);
        $(href).load(url,function(result){
            pane.tab('show');

        });
    });


    //$(".tabs-style-underline").swipe( {
////Generic swipe handler for all directions
//swipeLeft:function(event, direction, distance, duration, fingerCount) {
////$(this).parent().carousel('prev');
////alert("SINISTRA");
////console.log($("ul li.tab-current").prev("li").find("a"));
//$("ul li.tab-current").prev("li").find('a').click();
////var id = $("li").children().length;
//},
//swipeRight: function() {
////$(this).parent().carousel('next');
////console.log($("ul li.tab-current").next("li").find("a"));
//$("#myTabs > .tab-current").next("li").find('a').trigger("click");

//},
////Default is 75px, set to 0 for demo so any distance triggers swipe
//threshold:0
//});
// Hide Header on on scroll down

//                                                    DA QUI

var didScroll;
var lastScrollTop = 0;
var delta = 20;
var navbarHeight = $('header').outerHeight();

$(window).scroll(function(event){
    didScroll = true;
});

setInterval(function() {
    if (didScroll) {
        hasScrolled();
        didScroll = false;
    }
}, 250);

function hasScrolled() {
    var st = $(this).scrollTop();

    // Make sure they scroll more than delta
    if(Math.abs(lastScrollTop - st) <= delta)
        return;

    // If they scrolled down and are past the navbar, add class .nav-up.
    // This is necessary so you never see what is "behind" the navbar.
    if (st > lastScrollTop && st > navbarHeight){
        // Scroll Down
        //$('.navbar').hide("100");
         $('.secondo-menu').slideUp();
         $('.primo-menu').slideUp();
    } else {
        // Scroll Up
        if(st + $(window).height() < $(document).height()) {
            //$('.navbar').show("100");
            $('.primo-menu').slideDown();
            $('.secondo-menu').slideDown();
        }
    }

    lastScrollTop = st;
}

// A QUI

var a = $('#ricerca_entry_articolo_modal').autocomplete({
    serviceUrl:'/pg/as_Ente/GetEnti?servizio=ItaliaCives',
    minChars:2,
    delimiter: /(,|;)\s*/, // regex or character
    maxHeight:400,
    width:300,
    zIndex: 9999,
    deferRequestBy: 0, //miliseconds
    //params: { country:'Yes' }, //aditional parameters
    noCache: false, //default is false, set to true to disable caching
    // callback function:
    onSelect: function(value, data){
        $("#id_ente").val(value.id_ente);
        },
    // local autosugest options:
    //lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values
});

  //$('#hook').hook();

});
</script>
{% endblock %}
</body>
</html>
